<?php
namespace Admin\Controller;
use Common\Controller\BaseController;
class CarNoController extends BaseController{

    protected function _initialize(){
        parent::_initialize();
        $this->checkAuth();
        $this->model = D('order');
    }

    /**
     * 列表
     */
    public function index(){
        if(IS_AJAX){
            //排序
            $order = I('get.order');
            //获取列表
            $field = "pk_id,query_car_no,FROM_UNIXTIME(query_datetime) AS query_datetime,CASE WHEN stage=1 THEN '待查询' WHEN stage=2 THEN '已完成' WHEN stage=3 THEN '查询失败' END stage,create_time";
            $data = $this->getRows('order', $map ,$field ,$order);
            $this->data = $data;
            $this->rtnResult(0);
        }else{
            //表头、字段名
            $data['field'] = 'query_car_no,query_datetime,stage,create_time';
            $data['titleArr'] = array('车牌号','查询时间','车牌号状态','添加时间');
            $this->showView($data);
        }
    }

    /**
     * 编辑
     */
    public function edit(){
            $pk_id=I('get.pk_id');
            !$pk_id && exit('参数不全');
            $where['_string']='o.fk_user_id=u.pk_id';
            $where['o.pk_id']=$pk_id;
            $where['o.stage']=1;
            $where['o.status']=0;
            $field="o.pk_id,o.query_car_no,o.query_datetime,o.create_time,u.name";
            $data['info']=M()->table(array('order'=>'o','user'=>'u'))->where($where)->field($field)->find();
            if(empty($data['info'])){
                exit('非法操作');
            }else{
                $this->showView($data);
            }
    }

}
